
import { defineStore } from 'pinia'

export const useCollectionStore = defineStore('collection', {
  state: () => ({
    collections: [
      {
        id: 1,
        name: '青花仙子',
        price: 299,
        rarity: '限量',
        description: '传统青花瓷纹与现代设计的完美结合'
      },
      {
        id: 2,
        name: '青花舞者',
        price: 399,
        rarity: '珍藏',
        description: '优雅的舞姿中流淌着千年瓷韵'
      }
    ]
  }),
  
  actions: {
    addToCollection(doll) {
      const exists = this.collections.find(item => item.id === doll.id)
      if (!exists) {
        this.collections.push(doll)
      }
    },
    
    removeFromCollection(id) {
      const index = this.collections.findIndex(item => item.id === id)
      if (index > -1) {
        this.collections.splice(index, 1)
      }
    },
    
    isInCollection(id) {
      return this.collections.some(item => item.id === id)
    }
  },
  
  persist: true
})
